package org.rcy.service;

import org.rcy.dao.HiringInfoDao;
import org.rcy.framework.api.entity.PageResult;
import org.rcy.framework.data.service.BaseCrudService;
import org.rcy.po.HiringInfo;
import org.rcy.vo.InfoQueryCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HiringInfoService extends BaseCrudService<HiringInfo> {

	@Autowired
	private HiringInfoDao infoDao;

	public void saveInfo(HiringInfo info) {
		infoDao.save(info);
	}

	public void deleteOne(Long id) {
		infoDao.delete(id);
	}

	public HiringInfo getDetail(Long id) {
		return infoDao.get(id);
	}

	public PageResult<HiringInfo> queryPage(InfoQueryCondition condition) {
		PageResult<HiringInfo> page = new PageResult<>();
		page.setPageNo(condition.getPageNo());
		page.setPageSize(condition.getPageSize());
		long totalCount = infoDao.countInfo(condition);
		if(totalCount <= 0) {
			return page;
		}
		List<HiringInfo> infoList = infoDao.queryCondition(condition);
		page.setResult(infoList);
		page.setRecordTotal(Integer.valueOf(totalCount + ""));
		return page;
	}

}
